package com.zhouqinuan.spring.cloud.develop.framework.demo.routing.datasource.controller;

import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import com.zhouqinuan.spring.cloud.develop.framework.demo.routing.datasource.req.AddUserReq;
import com.zhouqinuan.spring.cloud.develop.framework.demo.routing.datasource.req.GetUserInfoByIdReq;
import com.zhouqinuan.spring.cloud.develop.framework.demo.routing.datasource.req.UpdateUserReq;
import com.zhouqinuan.spring.cloud.develop.framework.demo.routing.datasource.resp.GetUserInfoByIdResp;
import com.zhouqinuan.spring.cloud.develop.framework.demo.routing.datasource.service.UserService;

import io.swagger.annotations.Api;

@Api(tags = "用户模块")
@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("/user/getUserInfoById")
    public GetUserInfoByIdResp getUserInfoById(@Valid @RequestBody GetUserInfoByIdReq reqVO) throws Exception {
        return userService.getUserInfoById(reqVO);
    }

    @PostMapping("/user/addUser")
    public int addUser(@Valid @RequestBody AddUserReq reqVO) throws Exception {
        return userService.addUser(reqVO);
    }

    @PostMapping("/user/updateUser")
    public int updateUser(@Valid @RequestBody UpdateUserReq reqVO) throws Exception {
        return userService.updateUser(reqVO);
    }
}
